package com.atguigu.spzx.user.controller;

import com.atguigu.spyx.model.common.Result;
import com.atguigu.spyx.model.common.com.atguigu.spyx.model.entity.h5.UserAddress;
import com.atguigu.spzx.user.service.UserAddressService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LT
 * @create 2023-11-21-17:59
 */
@RestController
@RequestMapping("/api/user/userAddress")
public class UserAddressController {

    @Resource
    UserAddressService userAddressService;

    @GetMapping("/findUserAddressById/{id}")
    public Result findUserAddressById(@PathVariable("id")Long id){
        UserAddress userAddress = userAddressService.findUserAddressById(id);
        return Result.ok().data(userAddress);
    }

    @GetMapping("/auth/findUserAddressList")
    public Result findUserAddressList(){
        List<UserAddress> userAddresses = userAddressService.findUserAddressList();
        return Result.ok().data(userAddresses);
    }
    @PostMapping("/auth/save")
    public Result save(@RequestBody UserAddress userAddress){
        userAddressService.save(userAddress);
        return Result.ok();
    }



}
